home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-05 / driverss.zip / PKTCHK.ASM < prev    next >
Assembly Source File  |  1990-12-23  |  4KB  |  155 lines

  1. version    equ    1
  2.  
  3. ;  Russell Nelson, Clarkson University.  October 20, 1988
  4. ;  Copyright, 1988, 1989, Russell Nelson
  5. ;  Modified TERMIN.ASM to be PKTCHK.ASM return errorlevel, don't terminate
  6. ;    07/24/89 Glen Marianko, Albert Einstein College of Medicine
  7.  
  8. ;   This program is free software; you can redistribute it and/or modify
  9. ;   it under the terms of the GNU General Public License as published by
  10. ;   the Free Software Foundation, version 1.
  11. ;
  12. ;   This program is distributed in the hope that it will be useful,
  13. ;   but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. ;   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15. ;   GNU General Public License for more details.
  16. ;
  17. ;   You should have received a copy of the GNU General Public License
  18. ;   along with this program; if not, write to the Free Software
  19. ;   Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  20.  
  21.     include    defs.asm
  22.  
  23. code    segment word public
  24.     assume    cs:code, ds:code
  25.  
  26.     org    80h
  27. phd_dioa    label    byte
  28.  
  29.     org    100h
  30. start:
  31.     jmp    start_1
  32.  
  33. copyleft_msg    label    byte
  34.  db "Packet checker version ",'0'+majver,".",'0'+version," copyright 1990, Russell Nelson.",CR,LF
  35.  db "This program is free software; see the file COPYING for details.",CR,LF
  36.  db "NO WARRANTY; see the file COPYING for details.",CR,LF
  37.  
  38. int_pkt    macro
  39.     pushf
  40.     cli
  41.     call    their_isr
  42.     endm
  43.  
  44. their_isr    dd    ?
  45. packet_int_no    db    0,?,?,?
  46. packet_int_end  db    0,?,?,?
  47. signature    db    'PKT DRVR',0
  48. signature_len    equ    $-signature
  49. got_int        db    0
  50. no_signature_msg    db    "Packet driver not found.",CR,LF,'$'
  51. signature_msg    db    "Packet driver found at ",'$'
  52. no_signatures_msg    db    "No packet driver found in specified range.",CR,LF,'$'
  53. usage_msg    db    "usage: pktchk <packet_int_no> (packet_int_no_end)",CR,LF,'$'
  54.  
  55. usage_error:
  56.     mov    dx,offset usage_msg
  57. error:
  58.     mov    ah,9
  59.     int    21h
  60. err_quit:
  61.     mov    al,1
  62.         mov     ah,04ch                 ; exit with errorlevel 1
  63.         int     21h
  64.  
  65. start_1:
  66.     mov    si,offset phd_dioa+1
  67.     call    skip_blanks
  68.     cmp    al,CR            ;end of line?
  69.     je    usage_error
  70.  
  71.     mov    di,offset packet_int_no
  72.     call    get_number
  73.     cmp    packet_int_no+1,0
  74.     jne    usage_error
  75.  
  76.     mov    di,offset packet_int_end
  77.     call    get_number
  78.     cmp    packet_int_end+1,0
  79.     jne    usage_error
  80.     mov    di,si
  81.     call    skip_blanks
  82.     cmp    al,CR            ;end of line?
  83.     jne    usage_error
  84.  
  85.     cmp    packet_int_end,0
  86.     jne    chk_range        ; second arg specified
  87.  
  88.     call    chk_int
  89.     jne    no_signature_err
  90.     call    pkt_found
  91. all_done:
  92.     mov    al,0
  93.     mov    ah,04ch
  94.     int    21h            ; exit with errorlevel 0
  95.  
  96. no_signature_err:
  97.     mov    dx,offset no_signature_msg
  98.     jmp    error
  99.  
  100. chk_range:
  101.     mov    al,packet_int_end
  102.     sub    al,packet_int_no
  103.     jc    usage_error
  104.  
  105. chk_loop:
  106.     call    chk_int
  107.     jne    chk_none
  108.     call    pkt_found
  109.     inc    got_int            ; flag we got one
  110. chk_none:
  111.     mov    al,packet_int_no
  112.     cmp    packet_int_end,al
  113.     jz    no_signatures_chk
  114.     inc    packet_int_no        ; increment
  115.     jmp    chk_loop
  116.  
  117. no_signatures_chk:
  118.     cmp    got_int,0
  119.     jnz    all_done
  120.  
  121. no_signatures:
  122.     mov    dx,offset no_signatures_msg
  123.     jmp    error
  124.  
  125.     public    chk_int
  126. chk_int:
  127.     mov    ah,35h            ;get their packet interrupt.
  128.     mov    al,packet_int_no
  129.     int    21h
  130.     mov    their_isr.offs,bx
  131.     mov    their_isr.segm,es
  132.     lea    di,3[bx]
  133.     mov    si,offset signature
  134.     mov    cx,signature_len
  135.     repe    cmpsb
  136.     ret
  137.  
  138.     public    pkt_found
  139. pkt_found:
  140.     mov    dx,offset signature_msg
  141.     mov    di,offset packet_int_no
  142.     jmp    print_number
  143.  
  144.     include    getnum.asm
  145.     include    skipblk.asm
  146.     include    getdig.asm
  147.     include    decout.asm
  148.     include    digout.asm
  149.     include    chrout.asm
  150.     include    printnum.asm
  151.  
  152. code    ends
  153.  
  154.     end    start
  155.